package com.me.collector;

import java.util.ArrayList;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.CircleShape;
import com.badlogic.gdx.physics.box2d.Shape;
import com.me.collector.Definitions.EntityCategory;
import com.me.collector.Definitions.ItemType;

public abstract class Item {
	protected ItemType type;
	protected int score;
	protected Texture texture;
	protected int width;
	protected int height;
	protected short category = (short)EntityCategory.Item.getValue();
	protected short mask = (short)((short)EntityCategory.Item.getValue() |
			(short)EntityCategory.Container.getValue() |
			(short)EntityCategory.Ground.getValue());
	static ArrayList<Item> childs = new ArrayList<Item>();
	
	// Define these properties in constructor !
	public Item(String texturePath, int width, int height, int score)
	{
		texture = new Texture(Gdx.files.internal(texturePath));
		
		this.width = width;
		this.height = height;
		
		this.score = score;
		
		childs.add(this);
	}
	
	public abstract ArrayList<Shape> createShapes();
	
	public abstract void effect(Hero hero, FallingObject o, FallingItems fItems);
	
	public void impact(Hero hero, FallingObject o, FallingItems fItems, Ground ground)
	{
		// Raise ground ?
		// ground.raiseGround(o.getPosition().add(new Vector2(o.getItem().getWidth() * 0.5f, 0)));
		o.remove();
	}
	
	// properties
	
	public int getScore()
	{
		return score;
	}
	
	public int getWidth()
	{
		return width;
	}
	
	public int getHeight()
	{
		return height;
	}
	
	public Texture getTexture()
	{
		return texture;
	}
	
	public short getCategory()
	{
		return category;
	}
	
	public short getMask()
	{
		return mask;
	}
	
	public ItemType getType()
	{
		return type;
	}
	
	public static ArrayList<Item> getAllItems()
	{
		return childs;
	}
}